package com.gxa.autoparts.admin.service.impl;

import com.gxa.autoparts.admin.mapper.AttributeKeyMapper;
import com.gxa.autoparts.admin.service.AttributeKeyService;
import com.gxa.autoparts.core.pojo.AttributeKey;
import com.gxa.autoparts.core.pojo.AttributeValue;
import com.gxa.autoparts.core.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("attributeKeyService")
public class AttributeKeyServiceImpl extends BaseServiceImpl<AttributeKey> implements AttributeKeyService {
    @Resource
    AttributeKeyMapper attributeKeyMapper;
    @Override
    public List<AttributeValue> selectAttributeValueById(Long attributeKeyId) throws Exception {
        List<AttributeValue> attributeValues = attributeKeyMapper.selectAttributeValueById(attributeKeyId);
        if(attributeValues==null){
            throw new Exception("没有查到数据");
        }
        return attributeValues;
    }

    @Override
    public List<AttributeKey> selectAllAttributeKeyNameAndAttributeValueName(Long attributeKeyId) throws Exception {
        List<AttributeKey> attributeKeys = attributeKeyMapper.selectAllAttributeKeyNameAndAttributeValueName(attributeKeyId);
        if(attributeKeys==null){
            throw new Exception("没有查到数据");
        }
        return attributeKeys;
    }

    @Override
    public List<AttributeKey> selectAttributeKeyAndAttributeValue(Long typeId) throws Exception {
        List<AttributeKey> attributeKeys = attributeKeyMapper.selectAttributeKeyAndAttributeValue(typeId);
        if(attributeKeys==null){
            throw new Exception("没有查到数据");
        }
        return attributeKeys;
    }
}
